package com.example.demo.controller;

import com.example.demo.dao.PlayerRespository;
import com.example.demo.domain.Player;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/player")
@Api("swaggerDemoController相关的api")
public class PlayerController {

    @Resource
    PlayerRespository playerRespository;

    @PostMapping(value ="/one")
    @ResponseBody
    @ApiOperation(value="新增player")
    public String createPlayer(@RequestBody Player player){
        return playerRespository.save(player).toString();
    }

    @GetMapping(value = "/all")
    @ResponseBody
    public Iterable<Player> findAll(){
        return playerRespository.findAll();
    }

}
